import { Toast, MessageBox, Indicator } from 'mint-ui';
export default {
    getRect(el) {
        if (el.getBoundingClientRect) {
            var rect = el.getBoundingClientRect();
            return {
                top: rect.top,
                left: rect.left,
                width: rect.width,
                height: rect.height
            }
        }
        return {
          top: el.offsetTop,
          left: el.offsetLeft,
          width: el.offsetWidth,
          height: el.offsetHeight
        }
    },

    toast (msg, options) {
        let instance = Toast(Object.assign({
            message: msg
        }, options || {}));
        setTimeout(() => {
            instance.close();
        }, 2000);
        return instance;
    },

    alert (msg, title, options) {
        return MessageBox(Object.assign({
            title: title || '',
            message: msg || ''
        }, options || {}));
    },

    load (msg) {
        Indicator.open({
            text: msg,
            spinnerType: 'fading-circle'
        });
        return Indicator;
    }
}